﻿using System;
using Caliburn.Micro;
using PocketBook.Model;
using PocketBook.Tasks;

namespace PocketBook.ViewModels
{
    public abstract class DesignEditor : Screen, IDesignEditor 
    {
        private IDesign _design;

        public event EventHandler<DialogResultCompletionEventArgs> Completed;

        public IDesign Design
        {
            get { return _design; }
            set
            {
                _design = value;
                if (Design != null) DisplayName = "Edit " + Design.DisplayName;
            }
        }

        public void Save()
        {
            TryClose(true);
        }
    }

    public abstract class DesignEditor<TSettings> : DesignEditor
        where TSettings : class, ICloneable, new()
    {
        public TSettings Settings
        {
            get { return ((CustomisableDesign<TSettings>)Design).Settings; }
        }
    }
}